package com.medord.flow;

import com.medord.dao.StudentDao;
import com.medord.entity.Student;
import com.medord.flow.aspect.CheckFlowHandler;
import com.medord.flow.aspect.CheckFlowHandler2;
import com.medord.machine.core.FlowConstant;
import com.medord.machine.core.annotition.FlowAspectAnno;
import com.medord.machine.core.annotition.StateService;
import com.medord.machine.core.FlowState;
import com.medord.machine.core.annotition.TargetStateMethod;
import com.medord.machine.core.entity.ICurrentStateDto;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 孙丰佳
 * @version V1.0
 * @Title: Cd11State
 * @Package com.medord.machine.core
 * @Description: (用一句话描述该文件做什么)
 * @date 2021-08-01 15:38
 **/
@StateService(flowName = FlowConstant.MED_FLOW_NAME, state = FlowConstant.CD_11, stateDes = FlowConstant.NA_11)
public class Cd11State extends FlowState {

    @Autowired
    private StudentDao studentDao;

    //到已签署
    @SneakyThrows
    @TargetStateMethod(target = FlowConstant.CD_21)
    @FlowAspectAnno(prefixCheckNames = {CheckFlowHandler.class, CheckFlowHandler2.class},
            suffixCheckNames = {CheckFlowHandler.class, CheckFlowHandler2.class})
    public String toCd21State(ICurrentStateDto iCurrentStateDto) {
        this.putInnerPara("name", "sun");
        Student student = (Student) iCurrentStateDto.get();
        student.setStatus(FlowConstant.CD_21);
        studentDao.updateStudent(student);
//        TimeUnit.MILLISECONDS.sleep(4000);
        this.addWarningMsg(Thread.currentThread().getName());
        String msg = "【" + iCurrentStateDto.getName() + "】状态变化为【已签署】成功!";
        return msg;
    }


}
